import Layer from '../core/Layer';

export default class extends Layer {
    constructor(canvas, style, director) {
        super(canvas, style);
        this.actors = [];
        this.director = director;
        // this.entryAction = style.entryAction;
        // this.leaveAction = style.leaveAction;
    }

    addActor(actor) {
        this.actors.push(actor);
        this.addChild(actor.player);
    }

    play() {
        const actorPromise = this.actors.map(vo => {
            return vo.play();
        });
        Promise.all(actorPromise).then(() => {
           if (this.director.hasNext()) {
               const nextScene = this.director.next();
               this.director.runScene(nextScene);
           }
        });
    }
}
